<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	protected function _initViews()
	{
		$this->bootstrap('view');
		$view = $this->getResource('view');
	
		$view->doctype('HTML5');
		Zend_Registry::set('view',$view);
	
		$view->headTitle()->setSeparator(' - ')->headTitle('Votei.Net');
		$view->headMeta()->appendHttpEquiv('Content-type','text/html;charset=utf-8');
	}
	
	protected function _initAutoLoader()
	{
		$autoloader = Zend_Loader_Autoloader::getInstance();
		$autoloader->setFallbackAutoloader(true);
	}
	
	protected function _initConfig()
	{
		$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
		Zend_Registry::set('config', $config);
	}
	
	protected function _initPlugins()
	{
		$bootstrap = $this->getApplication();
		if($bootstrap instanceof Zend_Application)
			$bootstrap = $this;
	
		$bootstrap->bootstrap('FrontController');
		$front = $bootstrap->getResource('FrontController');
	
		$front->registerPlugin(new SON_Plugins_Layout());
		//$front->registerPlugin(new SON_Plugins_IDS());
	}
	
	protected function _initAcl()
	{	
		$front = Zend_Controller_Front::getInstance();
		$front->registerPlugin(new SON_Plugins_CheckAcl(new Acl()));
	}
	
	protected function _initLogger()
	{
		$format = '%timestamp% %priorityName% (%priority%): %message%' . PHP_EOL;
		$formatter = new Zend_Log_Formatter_Simple($format);
		
		$writer = new Zend_Log_Writer_Stream('../var/log/system.log');
		$writer->setFormatter($formatter);
		
		$logger = new Zend_Log();
		$logger->addWriter($writer);
		
		Zend_Registry::set('logger', $logger);
	}
}

